<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>待认领订单列表</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="../../resource/hotui/css/plugins/morris/morris-0.4.3.min.css"
          th:href="@{/resource/hotui/css/plugins/morris/morris-0.4.3.min.css}" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>

</head>

<body th:object="${order}">
<form id="saveForm">
    <div class="wrapper wrapper-content tooltip-demo" style="max-height: 492px; overflow-y: auto;">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins" style="margin-bottom: 0;">
                    <div class="ibox-title" style="padding: 0; min-height: initial;">
                        <div class="form-inline">
                            <div class="form-group m-r-sm">
                                <input type="hidden" th:value="*{subOrderId}" id="orderId"/>
                                <label style="font-size: 17px;">订单：<span
                                        th:text="*{subOrderId}">20170110893091324683</span></label>
                            </div>
                            <div class="form-group m-r-sm" style="float: right;">
                                <label style="font-size: 14px; font-weight: normal;">
                                    <span class="glyphicon glyphicon-time"></span>
                                    <span th:text="*{#temporals.format(createTime,'yyyy-MM-dd HH:mm:ss')}">2017/1/10 21:08:44</span></label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins m-b-none">
                    <div class="ibox-content p-xxs no-borders" style="border-top: none;">
                        <table class="table table-bordered">
                            <tbody>
                            <tr>
                                <th>物流公司：</th>
                                <td class="form-inline">
                                    <div class="form-group m-b-none">
                                        <select name="expressCompanyCode" id="expressCompanyCode"
                                                class="form-control input-sm">
                                            <option>请选择</option>
                                            <option th:each="expressCompany:${expressCompanies}"
                                                    th:text="${expressCompany.desc}"
                                                    th:value="${expressCompany.code}">中国邮政
                                            </option>
                                        </select>
                                    </div>
                                </td>
                                <th>物流单号：</th>
                                <td>
                                    <div class="form-group m-b-none">
                                        <input name="expressNumber" type="text" id="expressNumber"
                                               class="form-control input-sm" required placeholder="物流单号"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>物流费用：</th>
                                <td>
                                    <div class="form-group form-inline m-b-none">
                                        <div class="input-group" style="width: 130px;">
                                            <span class="input-group-addon">¥</span>
                                            <input name="freightAmount" th:value="*{freightAmount}" type="text"
                                                   id="freightAmount"
                                                   class="form-control input-sm only-float" placeholder="物流费用"/>
                                        </div>
                                        <p class="form-control-static color-notice">不填默认运费为0</p>
                                    </div>

                                </td>
                                <th>邮政编码：</th>
                                <td>
                                    <input name="zipCode" type="text" id="zipCode" readonly
                                           class="form-control input-sm only-num" maxlength="6"
                                           th:value="*{orderPO.receivingInfo.postalCode}" placeholder="邮政编码"/>
                                </td>
                            </tr>
                            <tr>
                                <th>收货人姓名：</th>
                                <td>
                                    <div class="form-group m-b-none">
                                        <input name="receiver" type="text" id="receiver" class="form-control input-sm"
                                               readonly
                                               required placeholder="收货人姓名" th:value="*{orderPO.receivingInfo.userName}"
                                               value="大师傅"/>
                                    </div>
                                </td>
                                <th>电话：</th>
                                <td>
                                    <input name="phone" type="text" id="phone" readonly
                                           class="form-control input-sm only-num"
                                           placeholder="电话"/>
                                </td>
                            </tr>
                            <tr>
                                <th>手机：</th>
                                <td>
                                    <div class="form-group m-b-none">
                                        <input name="mobile" type="text" id="mobile" readonly
                                               th:value="*{orderPO.receivingInfo.telNumber}"
                                               class="form-control input-sm only-num" placeholder="手机"
                                               value="15267150743"/>
                                    </div>

                                </td>
                                <th>地址：</th>
                                <td>
                                    <div class="form-group m-b-none">
                                        <input name="receivingAddress" type="text" id="receivingAddress" readonly
                                               style="width: 300px;" required class="form-control input-sm"
                                               th:value="*{orderPO.receivingInfo.fullAddress()}"
                                               placeholder="地址" value="湖北省随州市曾都区的萨芬"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>发货单备注：</th>
                                <td colspan="3">
                                    <textarea placeholder="发货单备注" name="remarks" id="remarks" class="form-control"
                                              rows="5" style="height: 56px;"></textarea>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row" style="padding: 0 15px; position: absolute; bottom: 0; width: 100%;">
        <div class="col-lg-12">
            <div class="ibox float-e-margins" style="margin-bottom: 0;">
                <div class="ibox-title" style="padding: 0; min-height: initial;">
                    <div class="form-group " style="float: right;">
                        <button type="submit" class="btn btn-primary">发货</button>
                        <button type="submit" class="btn btn-white m-l" onclick="javascript:parent.layer.close(index);">
                            关闭
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script src="../../resource/hotui/js/plugins/validate/jquery.validate.min.js"
        th:src="@{/resource/hotui/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="../../resource/hotui/js/plugins/validate/messages_zh.min.js"
        th:src="@{/resource/hotui/js/plugins/validate/messages_zh.min.js}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-validate.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-validate.js}"></script>

<script type="text/javascript" th:inline="javascript">
    var deliverUri = /*[[@{/order/deliver}]]*/ "";
</script>

<script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name);

    $("#saveForm").validateCallback(function () {
        let freightAmount = $.trim($("#freightAmount").val());
        if (freightAmount.length === 0) {
            freightAmount = 0;
        }
        let orderId = $.trim($("#orderId").val());
        let expressCompany = $.trim($("#expressCompanyCode option:selected").text());
        let expressComCode = $.trim($("#expressCompanyCode").val());
        let expressNo = $.trim($("#expressNumber").val());
        let remark = $.trim($("#remarks").val());

        let requestData = {
            freightAmount: freightAmount,
            expressCompany: expressCompany,
            expressComCode: expressComCode,
            expressNo: expressNo,
            remark: remark,
            orderId: orderId
        };

        hot.ajax(deliverUri, requestData, function (apiResult) {
            if (apiResult.resultCode === 2000) {
                hot.tip.success("发货成功", function () {
                    parent.location.reload();
                    parent.layer.close(index);
                });
            } else {
                hot.tip.error(apiResult.resultMsg);
            }
        }, function () {
        }, "post");
    }, {
        ignore: "",
        rules: {
            txtShipMobile: {
                mobile: true,
                required: true
            }
        }
    });
</script>
</body>

</html>
